﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeBehind="Product.aspx.cs" Inherits="GPSTracker.Views.Master.Product" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <link href="../CSS/Product.css" rel="stylesheet" />
    <script src="../JS/ProductJS.js"></script>

    <script language="javascript" type="text/javascript">

        function Fade(div) {
            setTimeout("document.getElementById('" + div + "').style.display='none'", 4000);
        }

    </script>

    <asp:ScriptManager ID="scrptMgr" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpMain" runat="server" UpdateMode="Conditional">
        <ContentTemplate>

            <table cellspacing="5" cellpadding="5" width="98%" border="0" align="center">
                <tr>
                    <td style="width: 100%; height: 100%; text-align: center;">
                        <fieldset class="FiledSetDesign" style="border: 1px solid #cccccc; padding: 0; margin: 0;">
                            <legend class="PageHeading" align="center" style="color: #f1b20c; font-weight: bold; font-size: 18px; text-align: center;">
                                <asp:Label ID="lblHead" runat="server" Text="Product Master"></asp:Label>
                            </legend>

                            <table style="width: 100%; height: 100%" align="center" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td style="padding: 5px; width: 100%; height: 89%; overflow: auto;">
                                        <dx:ASPxGridView ID="grdView" runat="server" AutoGenerateColumns="false"
                                            ClientInstanceName="grdView" OnCustomButtonCallback="grdView_CustomButtonCallback"
                                            KeyFieldName="ProductID" EnableCallBacks="false" DataSourceID="SqlDataSource1">
                                            <Columns>
                                                <dx:GridViewCommandColumn VisibleIndex="0">
                                                    <ClearFilterButton Visible="True">
                                                    </ClearFilterButton>
                                                    <CustomButtons>
                                                        <dx:GridViewCommandColumnCustomButton ID="btnEdit" Text="Edit">
                                                        </dx:GridViewCommandColumnCustomButton>
                                                        <dx:GridViewCommandColumnCustomButton ID="btnDelete" Text="Delete">
                                                        </dx:GridViewCommandColumnCustomButton>
                                                    </CustomButtons>
                                                </dx:GridViewCommandColumn>
                                                <dx:GridViewDataColumn FieldName="ProductID" VisibleIndex="1" Visible="false"></dx:GridViewDataColumn>
                                                <dx:GridViewDataColumn FieldName="ProductCode" VisibleIndex="2"></dx:GridViewDataColumn>
                                                <dx:GridViewDataColumn FieldName="ProductName" VisibleIndex="3"></dx:GridViewDataColumn>
                                                <dx:GridViewDataColumn FieldName="ProductDesc" Caption="Product Description" VisibleIndex="4"></dx:GridViewDataColumn>
                                                <dx:GridViewDataColumn FieldName="IsActive" VisibleIndex="5"></dx:GridViewDataColumn>
                                                <dx:GridViewDataColumn FieldName="LoginName" Caption="Created By" VisibleIndex="6"></dx:GridViewDataColumn>
                                                <dx:GridViewDataColumn FieldName="CreatedDttm" VisibleIndex="7" Visible="false"></dx:GridViewDataColumn>
                                                <dx:GridViewDataColumn FieldName="ModifiedBy" VisibleIndex="8" Visible="false"></dx:GridViewDataColumn>
                                                <dx:GridViewDataColumn FieldName="ModifiedDttm" VisibleIndex="9" Visible="false"></dx:GridViewDataColumn>
                                            </Columns>
                                            <Settings ShowFilterRow="True" />
                                            <ClientSideEvents CustomButtonClick="function(s, e) {
                                                                if (e.buttonID == 'btnDelete'){
                                                                    e.processOnServer = confirm('Are you sure You Want To Delete???');
                                                                }
                                                                if(e.buttonID == 'btnEdit')
                                                                {
                                                                    e.processOnServer = true;
                                                                }
                                                            }" />
                                        </dx:ASPxGridView>
                                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MainConn %>" SelectCommand="SELECT * FROM dbo.VW_GetProduct WHERE ISNULL(IsActive,0) = 1"></asp:SqlDataSource>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="padding-top: 5px; padding-left: 5px; padding-right: 5px; height: 1%;">
                                        <hr style="height: 2px; border-style: solid; border-width: 1px 0 0 0; border-color: #cccccc;" />
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 30%; padding-left: 5px; padding-bottom: 5px; height: 10%;">
                                        <table style="width: 100%">
                                            <tr>
                                                <td style="float: left;">
                                                    <dx:ASPxButton ID="btnNew" runat="server" Text="Add New" Width="80"
                                                        OnClick="btnNew_Click">
                                                    </dx:ASPxButton>
                                                </td>
                                                <td style="float: left; padding-left: 5px;">
                                                    <dx:ASPxButton ID="btnRefresh" runat="server" Text="Refresh" OnClick="btnRefresh_Click"
                                                        Width="80">
                                                    </dx:ASPxButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </fieldset>
                    </td>
                </tr>
            </table>



            <dx:ASPxPopupControl ID="popup" ClientInstanceName="popup" runat="server" AllowDragging="true"
                Width="500px" PopupHorizontalAlign="WindowCenter" HeaderText="Add Login User" PopupVerticalAlign="WindowCenter">
                <ContentCollection>
                    <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                        <table width="100%" cellpadding="2" cellspacing="0">
                            <tr>
                                <td colspan="2" align="left" style="padding-bottom: 5px;">Field Marks With (<span style="color: Red;">*</span>) Are Mandatory<hr style="height: 2px; border-style: solid; border-width: 1px 0 0 0; border-color: #cccccc;" />
                                </td>
                            </tr>
                            <tr>
                                <td width="50%" align="left">Product Code <span style="color: Red;">*</span><br />
                                    <dx:ASPxTextBox ID="txtProductCode" runat="server" Width="200" CssClass="AllControls">
                                    </dx:ASPxTextBox>
                                    <asp:HiddenField ID="hdnProductID" runat="server" />
                                </td>
                                <td width="50%" align="left">Product Name <span style="color: Red;">*</span><br />
                                    <dx:ASPxTextBox ID="txtProductName" runat="server" Width="200" CssClass="AllControls">
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>Product Description
                                    <br />
                                    <dx:ASPxTextBox ID="txtProductDescription" runat="server" Width="200" CssClass="AllControls">
                                    </dx:ASPxTextBox>
                                </td>
                                <td>
                                    <dx:ASPxCheckBox ID="chkIsActive" runat="server" Text="Is Active">
                                    </dx:ASPxCheckBox>
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top: 5px;">
                                    <hr style="height: 2px; border-style: solid; border-width: 1px 0 0 0; border-color: #cccccc;" />
                                </td>
                                <td style="padding-top: 5px;">
                                    <hr style="height: 2px; border-style: solid; border-width: 1px 0 0 0; border-color: #cccccc;" />
                                </td>
                            </tr>
                            <tr>                                
                                <td style="padding-right: 10px; text-align: left; float: left;width:50%;" >
                                    <dx:ASPxButton ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" Width="80">
                                        <ClientSideEvents Click="function(s, e)
                                            {
                                                if(Validate() == true)
                                                {
                                                    e.processOnServer = true; 
                                                }
                                                else
                                                {
                                                    e.processOnServer = false;
                                                }
                                            }
                                        " />
                                    </dx:ASPxButton>
                                    <dx:ASPxButton ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click" Width="80">
                                        <ClientSideEvents Click="function(s, e)
                                            {
                                                if(Validate() == true)
                                                {
                                                    e.processOnServer = true; 
                                                }
                                                else
                                                {
                                                    e.processOnServer = false;
                                                }
                                            }
                                        " />
                                    </dx:ASPxButton>
                                </td>
                                <td style="width:50%;text-align:left;vertical-align:middle;">
                                    <dx:ASPxLabel ID="lblMessage" runat="server" Visible="false" Text="">
                                    </dx:ASPxLabel>
                                </td>
                            </tr>

                        </table>
                    </dx:PopupControlContentControl>
                </ContentCollection>
            </dx:ASPxPopupControl>

        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
